package model;

public class Student {
    private String studentNo;
    private String name;
    private String major;

    public Student(String studentNo, String name, String major) {
        this.studentNo = studentNo;
        this.name = name;
        this.major = major;
    }

    public String getStudentNo() {
        return studentNo;
    }

    public void setStudentNo(String studentNo) {
        if (studentNo == null || studentNo.isEmpty())
            throw new IllegalArgumentException("学号不能为空");
        this.studentNo = studentNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name == null || name.isEmpty())
            throw new IllegalArgumentException("姓名不能为空");
        this.name = name;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    @Override
    public String toString() {
        return studentNo + " - " + name + " (" + major + ")";
    }
}
